﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
//using System.Web.UI.WebControls;
using TTSBLL;
using TTS;
using TTSModel;

public partial class T0002358_AllAdd : System.Web.UI.Page
{
    private Assemble a;
    private string message;
    private UnitType u;
    private KCCSNUnion ku;
    private AssembleInfo ainfo;
    private AssembleItem ai;
    //private string T0002358_SN = System.Guid.NewGuid().ToString(); //直接返回字符串类型
    private const string kccDownPEC_2368 = "KCQR02AA";
    private const string kccDownPEC_2053 = "KCQR05AA";
    //private const string kccDownPEC_2367 = "K0001688";
    private string[] kccDownPEC_2367 = new string[] { "K0001688", "KCQR07AA" };
    private const string kccDownPEC_2049 = "KCQR03AA";
    private const string kccDownPEC_2358 = "KCQR00AB";


    private string T0002358_TAK_SN { get { return ViewState["T0002358_TAK_SN"].ToString(); } set { ViewState["T0002358_TAK_SN"] = value; } }
    private string T0002368_SN { get { return ViewState["T0002368_SN"].ToString(); } set { ViewState["T0002368_SN"] = value; } }
    private string T0002358_KccUp_SN { get { return ViewState["T0002358_KccUp_SN"].ToString(); } set { ViewState["T0002358_KccUp_SN"] = value; } }
    private string T0002358_KccDown_SN { get { return ViewState["T0002358_KccDown_SN"].ToString(); } set { ViewState["T0002358_KccDown_SN"] = value; } }
    private string T0002368_KccUp_SN { get { return ViewState["T0002368_KccUp_SN"].ToString(); } set { ViewState["T0002368_KccUp_SN"] = value; } }
    private string T0002368_KccDown_SN { get { return ViewState["T0002368_KccDown_SN"].ToString(); } set { ViewState["T0002368_KccDown_SN"] = value; } }
    private string T0002049_Down_SN { get { return ViewState["T0002049_Down_SN"].ToString(); } set { ViewState["T0002049_Down_SN"] = value; } }
    private string T0002049_KccUp_SN { get { return ViewState["T0002049_KccUp_SN"].ToString(); } set { ViewState["T0002049_KccUp_SN"] = value; } }
    private string T0002049_KccDown_SN { get { return ViewState["T0002049_KccDown_SN"].ToString(); } set { ViewState["T0002049_KccDown_SN"] = value; } }
    private string T0002367_SN { get { return ViewState["T0002367_SN"].ToString(); } set { ViewState["T0002367_SN"] = value; } }
    private string T0002367_KccUp_SN { get { return ViewState["T0002367_KccUp_SN"].ToString(); } set { ViewState["T0002367_KccUp_SN"] = value; } }
    private string T0002367_KccDown_SN { get { return ViewState["T0002367_KccDown_SN"].ToString(); } set { ViewState["T0002367_KccDown_SN"] = value; } }
    private string T0002053_Left_SN { get { return ViewState["T0002053_Left_SN"].ToString(); } set { ViewState["T0002053_Left_SN"] = value; } }
    private string T0002053_LeftKccUp_SN { get { return ViewState["T0002053_LeftKccUp_SN"].ToString(); } set { ViewState["T0002053_LeftKccUp_SN"] = value; } }
    private string T0002053_LeftKccDown_SN { get { return ViewState["T0002053_LeftKccDown_SN"].ToString(); } set { ViewState["T0002053_LeftKccDown_SN"] = value; } }
    private string T0002053_Right_SN { get { return ViewState["T0002053_Right_SN"].ToString(); } set { ViewState["T0002053_Right_SN"] = value; } }
    private string T0002053_RightKccUp_SN { get { return ViewState["T0002053_RightKccUp_SN"].ToString(); } set { ViewState["T0002053_RightKccUp_SN"] = value; } }
    private string T0002053_RightKccDown_SN { get { return ViewState["T0002053_RightKccDown_SN"].ToString(); } set { ViewState["T0002053_RightKccDown_SN"] = value; } }

    private DataRow dr;
    private DataTable dt
    {
        get
        {
            return (DataTable)ViewState["dt"];
        }
        set
        {
            ViewState["dt"] = value;
        }
    }
    public T0002358_AllAdd()
    {
        a = new Assemble();
        u = new UnitType();
        ku = new KCCSNUnion();
        ainfo = new AssembleInfo();
        ai = new AssembleItem();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            dt = new DataTable();
            CommonHelper.AssembleItemDataTableInitialize(dt);
           
        }
        this.TextBox_T0002368_KccUp.Focus();
    }

    protected void TextBox_T0002358_KccUp_TextChanged(object sender, EventArgs e)
    {
        T0002358_KccUp_SN = this.TextBox_T0002358_KccUp.Text.Trim();
        if (SNHelper.KccUpSNCheck(T0002358_KccUp_SN, out message))
        {
            if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002358_KccUp_SN, out message))
            {
                this.TextBox_T0002358_KccUp.Enabled = false;
                this.TextBox_T0002358_KccDown.Enabled = true;
                this.TextBox_T0002358_KccDown.Focus();
                return;
                //this.ConfirmSubmit.Enabled = false;


            }
        }
        // ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        Page.ClientScript.RegisterStartupScript(this.GetType(), "y", "alert('" + message + "');", true);
        this.TextBox_T0002358_KccUp.Text = "";
        this.TextBox_T0002358_KccUp.Focus();
    }
    protected void TextBox_T0002358_KccDown_TextChanged(object sender, EventArgs e)
    {
        T0002358_KccDown_SN = this.TextBox_T0002358_KccDown.Text.Trim();

        if (SNHelper.KccDownSNCheck(T0002358_KccDown_SN, out message))
        {
            if (SNHelper.CheckKccDownPec(T0002358_KccDown_SN, kccDownPEC_2358, out message))
            {
                if (SNHelper.SNCheckKccDownVersion(T0002358_KccDown_SN, "03", out message))
                {
                    this.TextBox_T0002358_KccDown.Enabled = false;
                    this.TextBox_T0002358_TAKSN.Enabled = true;
                    this.TextBox_T0002358_TAKSN.Focus();
                    return;
                }
            }
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002358_KccDown.Text = "";
        this.TextBox_T0002358_KccDown.Focus();
    }


    protected void TextBox_T0002358_TAKSN_TextChanged(object sender, EventArgs e)
    {

        T0002358_TAK_SN = this.TextBox_T0002358_TAKSN.Text.Trim();

        if (SNHelper.TCodeSNCheck(T0002358_TAK_SN, out message)) //验证条码长度
        {
            if (SNHelper.SNCheckVersionThree(T0002358_TAK_SN, "E,01,F", out message))//验证版本是否正确
            {
                ainfo = a.Assemble_GetbySN(T0002358_TAK_SN);
                if (ai.AssembleItem_GetbyID(ainfo.ID).Count != 1)
                {
                    this.TextBox_T0002358_TAKSN.Enabled = false;
                    this.TextBox_T0002368_KccUp.Enabled = true;
                    this.TextBox_T0002368_KccUp.Focus();
                    return;
                }
                else
                {
                    message = "T0002358的条码已经存在，无法再次使用！";
                }
            }
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002358_TAKSN.Text = "";
        this.TextBox_T0002358_TAKSN.Focus(); 
    }

    protected void TextBox_T0002368_KccUp_TextChanged(object sender, EventArgs e)
    {
       /* T0002368_KccUp_SN = this.TextBox_T0002368_KccUp.Text.Trim();
        if (SNHelper.KccUpSNCheck(T0002368_KccUp_SN, out message))
        {
            if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002368_KccUp_SN, out message))
            {
                this.TextBox_T0002368_KccUp.Enabled = false;
                this.TextBox_T0002368_KccDown.Enabled = true;
                this.TextBox_T0002368_KccDown.Focus();
                return;
            }
        }
        // ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        Page.ClientScript.RegisterStartupScript(this.GetType(), "y", "alert('" + message + "');", true);
        this.TextBox_T0002368_KccUp.Text = "";
        this.TextBox_T0002368_KccUp.Focus();*/
        T0002368_KccUp_SN = this.TextBox_T0002368_KccUp.Text.Trim();
        if (SNHelper.KccUpSNCheck(T0002368_KccUp_SN, out message))
        {
            /*if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002368_KccUp_SN, out message))
            {
                this.TextBox_T0002368_KccUp.Enabled = false;
                this.TextBox_T0002368_KccDown.Enabled = true;
                this.TextBox_T0002368_KccDown.Focus();
                return;
            }*/
            if (!string.IsNullOrEmpty(ku.KCCSNUnion_GetbyKCCSN1(T0002368_KccUp_SN).SN))
            {
                T0002368_SN = ku.KCCSNUnion_GetbyKCCSN1(T0002368_KccUp_SN).SN;
               /* ainfo = a.Assemble_GetbySN(T0002368_SN);
                if (ai.AssembleItem_GetbyID(ainfo.ID).Count == 1)
                {
                    this.TextBox_T0002368_KccUp.Enabled = false;
                    this.TextBox_T0002368_KccDown.Enabled = true;
                    this.TextBox_T0002368_KccDown.Focus();
                    return;
                }
                else
                {
                    message = "T0002368的条码已经作为整机装配过，无法再次装配！";
                }*/
                if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002368_SN, "T0002368", out message))
                {
                    if (ProConditionHelper.CheckSubSNsPrecondition(T0002368_SN, "T0002368", out message))
                    {
                        this.TextBox_T0002368_KccUp.Enabled = false;
                        this.TextBox_T0002368_KccDown.Enabled = true;
                        this.TextBox_T0002368_KccDown.Focus();
                        return;
                    }
                }
            }
            else
            {
                message = "该KCC未装配过，请重新扫描正确的KCC！";
            }
        }
        // ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        Page.ClientScript.RegisterStartupScript(this.GetType(), "y", "alert('" + message + "');", true);
        this.TextBox_T0002368_KccUp.Text = "";
        this.TextBox_T0002368_KccUp.Focus();
    }
    protected void TextBox_T0002368_KccDown_TextChanged(object sender, EventArgs e)
    {
        T0002368_KccDown_SN = this.TextBox_T0002368_KccDown.Text.Trim();

        if (SNHelper.KccDownSNCheck(T0002368_KccDown_SN, out message))
        {
            if (SNHelper.CheckKccDownPec(T0002368_KccDown_SN, kccDownPEC_2368, out message))
            {
                if (SNHelper.SNCheckKccDownVersion(T0002368_KccDown_SN, "01", out message))
                {
                    this.TextBox_T0002368_KccDown.Enabled = false;
                    this.TextBox_T0002049_Up.Enabled = true;
                    this.TextBox_T0002049_Up.Focus();
                    return;
                }
            }
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002368_KccDown.Text = "";
        this.TextBox_T0002368_KccDown.Focus();
    }
    protected void TextBox_T0002049_Up_TextChanged(object sender, EventArgs e)
    {
        T0002049_KccUp_SN = this.TextBox_T0002049_Up.Text.Trim();
        if (SNHelper.KccUpSNCheck(T0002049_KccUp_SN, out message))
        {
            /*if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002368_KccUp_SN, out message))
            {
                this.TextBox_T0002368_KccUp.Enabled = false;
                this.TextBox_T0002368_KccDown.Enabled = true;
                this.TextBox_T0002368_KccDown.Focus();
                return;
            }*/
            if (!string.IsNullOrEmpty(ku.KCCSNUnion_GetbyKCCSN1(T0002049_KccUp_SN).SN))
            {
                T0002049_Down_SN = ku.KCCSNUnion_GetbyKCCSN1(T0002049_KccUp_SN).SN;
                if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002049_Down_SN, "T0002049", out message))
                {
                    if (ProConditionHelper.CheckSubSNsPrecondition(T0002049_Down_SN, "T0002049", out message))
                    {
                        this.TextBox_T0002049_Up.Enabled = false;
                        this.TextBox_T0002049_DownKccDown.Enabled = true;
                        this.TextBox_T0002049_DownKccDown.Focus();
                        return;
                        //this.ConfirmSubmit.Enabled = false;
                    }
                }

            }
            else
            {
                message = "该KCC未装配过，请重新扫描正确的KCC！";
            }
        }
        // ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        Page.ClientScript.RegisterStartupScript(this.GetType(), "y", "alert('" + message + "');", true);
        this.TextBox_T0002049_Up.Text = "";
        this.TextBox_T0002049_Up.Focus();
    }
    protected void TextBox_T0002049_DownKccDown_TextChanged(object sender, EventArgs e)
    {
        T0002049_KccDown_SN = this.TextBox_T0002049_DownKccDown.Text.Trim();

        if (SNHelper.KccDownSNCheck(T0002049_KccDown_SN, out message))
        {
            if (SNHelper.CheckKccDownPec(T0002049_KccDown_SN, kccDownPEC_2049, out message))
            {
                if (SNHelper.SNCheckKccDownVersion(T0002049_KccDown_SN, "03", out message))
                {
                    this.TextBox_T0002049_DownKccDown.Enabled = false;
                    this.TextBox_T0002367_KccUp.Enabled = true;
                    this.TextBox_T0002367_KccUp.Focus();
                    return;
                }
            }
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002049_DownKccDown.Text = "";
        this.TextBox_T0002049_DownKccDown.Focus();
    }
    protected void TextBox_T0002367_KccUp_TextChanged(object sender, EventArgs e)
    {
        T0002367_KccUp_SN = this.TextBox_T0002367_KccUp.Text.Trim();
        if (SNHelper.KccUpSNCheck(T0002367_KccUp_SN, out message))
        {
            /*if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002368_KccUp_SN, out message))
            {
                this.TextBox_T0002368_KccUp.Enabled = false;
                this.TextBox_T0002368_KccDown.Enabled = true;
                this.TextBox_T0002368_KccDown.Focus();
                return;
            }*/
            if (!string.IsNullOrEmpty(ku.KCCSNUnion_GetbyKCCSN1(T0002367_KccUp_SN).SN))
            {
                T0002367_SN = ku.KCCSNUnion_GetbyKCCSN1(T0002367_KccUp_SN).SN;
                if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002367_SN, "T0002367", out message))
                {
                    if (ProConditionHelper.CheckSubSNsPrecondition(T0002367_SN, "T0002367", out message))
                    {
                        this.TextBox_T0002367_KccUp.Enabled = false;
                        this.TextBox_T0002367_KccDown.Enabled = true;
                        this.TextBox_T0002367_KccDown.Focus();
                        return;
                        //this.ConfirmSubmit.Enabled = false;
                    }
                }

            }
            else
            {
                message = "该KCC未装配过，请重新扫描正确的KCC！";
            }
        }
        // ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        Page.ClientScript.RegisterStartupScript(this.GetType(), "y", "alert('" + message + "');", true);
        this.TextBox_T0002367_KccUp.Text = "";
        this.TextBox_T0002367_KccUp.Focus();
    }
    protected void TextBox_T0002367_KccDown_TextChanged(object sender, EventArgs e)
    {
        T0002367_KccDown_SN = this.TextBox_T0002367_KccDown.Text.Trim();

        if (SNHelper.KccDownSNCheck(T0002367_KccDown_SN, out message))
        {
            if (SNHelper.CheckKccDownPec(T0002367_KccDown_SN, kccDownPEC_2367, out message))
            {
                if (SNHelper.SNCheckKccDownVersion(T0002367_KccDown_SN, "01", out message))
                {
                    this.TextBox_T0002367_KccDown.Enabled = false;
                    this.TextBox_T0002053_LeftKccUp.Enabled = true;
                    this.TextBox_T0002053_LeftKccUp.Focus();
                    return;
                }
            }
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002367_KccDown.Text = "";
        this.TextBox_T0002367_KccDown.Focus();
    }
    protected void TextBox_T0002049_Down_TextChanged(object sender, EventArgs e)
    {
       /* T0002049_Down_SN = this.TextBox_T0002049_Down.Text.Trim();

        if (SNHelper.SNCheck(T0002049_Down_SN, "T0002049", out message))
        {
            if (SNHelper.SNCheckVersion(T0002049_Down_SN, this.T0002049_Down_Version.Text, out message))
            {
                if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002049_Down_SN, "T0002049", out message))
                {
                    if (ProConditionHelper.CheckSubSNsPrecondition(T0002049_Down_SN, "T0002049", out message))
                    {
                        this.TextBox_T0002049_Down.Enabled = false;
                        this.TextBox_T0002367.Enabled = true;
                        this.TextBox_T0002367.Focus();
                        return;
                        //this.ConfirmSubmit.Enabled = false;
                    }
                }
            }
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002049_Down.Text = "";
        this.TextBox_T0002049_Down.Focus();*/
    }
    protected void TextBox_T0002367_TextChanged(object sender, EventArgs e)
    {
        /*T0002367_SN = this.TextBox_T0002367.Text.Trim();

        if (SNHelper.SNCheck(T0002367_SN, "T0002367", out message))
        {
            if (SNHelper.SNCheckVersion(T0002367_SN, this.T0002367_Version.Text, out message))
            {
                if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002367_SN, "T0002367", out message))
                {
                    if (ProConditionHelper.CheckSubSNsPrecondition(T0002367_SN, "T0002367", out message))
                    {
                        this.TextBox_T0002367.Enabled = false;
                        this.TextBox_T0002053_Left.Enabled = true;
                        this.TextBox_T0002053_Left.Focus();
                        return;
                        //this.ConfirmSubmit.Enabled = false;
                    }
                }
            }
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002367.Text = "";
        this.TextBox_T0002367.Focus();*/
    }
   /* protected void TextBox_T0002053_Left_TextChanged(object sender, EventArgs e)
    {
        T0002053_Left_SN = this.TextBox_T0002053_Left.Text.Trim();
        if (SNHelper.SNCheck(T0002053_Left_SN, "T0002053", out message))
        {
            if (SNHelper.SNCheckVersion(T0002053_Left_SN, this.T0002053_Left_Version.Text, out message))
            {
                if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002053_Left_SN, "T0002053", out message))
                {
                    this.TextBox_T0002053_Left.Enabled = false;
                    this.TextBox_T0002053_LeftKccUp.Enabled = true;
                    this.TextBox_T0002053_LeftKccUp.Focus();
                    return;
                }
            }

        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002053_Left.Text = "";
        this.TextBox_T0002053_Left.Focus();
    }*/
    protected void TextBox_T0002053_LeftKccUp_TextChanged(object sender, EventArgs e)
    {
        T0002053_LeftKccUp_SN = this.TextBox_T0002053_LeftKccUp.Text.Trim();
       /* if (SNHelper.KccUpSNCheck(T0002053_LeftKccUp_SN, out message))
        {
            if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002053_LeftKccUp_SN, out message))
            {
                this.TextBox_T0002053_LeftKccUp.Enabled = false;
                this.TextBox_T0002053_LeftKccDown.Enabled = true;
                this.TextBox_T0002053_LeftKccDown.Focus();
                return;
            }
        }*/
        if (SNHelper.KccUpSNCheck(T0002053_LeftKccUp_SN, out message))
        {
            if (!string.IsNullOrEmpty(ku.KCCSNUnion_GetbyKCCSN1(T0002053_LeftKccUp_SN).SN))
            {
                T0002053_Left_SN = ku.KCCSNUnion_GetbyKCCSN1(T0002053_LeftKccUp_SN).SN;
                if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002053_Left_SN, "T0002053", out message))
                {
                    if (ProConditionHelper.CheckSubSNsPrecondition(T0002053_Left_SN, "T0002053", out message))
                    {
                        this.TextBox_T0002053_LeftKccUp.Enabled = false;
                        this.TextBox_T0002053_LeftKccDown.Enabled = true;
                        this.TextBox_T0002053_LeftKccDown.Focus();
                        return;
                        //this.ConfirmSubmit.Enabled = false;
                    }
                }

            }
            else
            {
                message = "该KCC未装配过，请重新扫描正确的KCC！";
            }
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002053_LeftKccUp.Text = "";
        this.TextBox_T0002053_LeftKccUp.Focus();
    }
    protected void TextBox_T0002053_LeftKccDown_TextChanged(object sender, EventArgs e)
    {
        T0002053_LeftKccDown_SN = this.TextBox_T0002053_LeftKccDown.Text.Trim();
        if (SNHelper.KccDownSNCheck(T0002053_LeftKccDown_SN, out message))
        {
            if (SNHelper.CheckKccDownPec(T0002053_LeftKccDown_SN, kccDownPEC_2053, out message))
            {
                if (SNHelper.SNCheckKccDownVersion(T0002053_LeftKccDown_SN, "01", out message))
                {
                    this.TextBox_T0002053_LeftKccDown.Enabled = false;
                    this.TextBox_T0002053_RightKccUp.Enabled = true;
                    this.TextBox_T0002053_RightKccUp.Focus();
                    return;
                }
            }

        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002053_LeftKccDown.Text = "";
        this.TextBox_T0002053_LeftKccDown.Focus();
    }
  
    protected void TextBox_T0002053_RightKccUp_TextChanged(object sender, EventArgs e)
    {
        T0002053_RightKccUp_SN = this.TextBox_T0002053_RightKccUp.Text.Trim();
        if (T0002053_LeftKccUp_SN != T0002053_RightKccUp_SN)
        {
           /* if (SNHelper.KccUpSNCheck(T0002053_RightKccUp_SN, out message))
            {
                if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002053_RightKccUp_SN, out message))
                {
                    this.TextBox_T0002053_RightKccUp.Enabled = false;
                    this.TextBox_T0002053_RightKccDown.Enabled = true;
                    this.TextBox_T0002053_RightKccDown.Focus();
                    return;
                }
            }*/
            if (!string.IsNullOrEmpty(ku.KCCSNUnion_GetbyKCCSN1(T0002053_RightKccUp_SN).SN))
            {
                T0002053_Right_SN = ku.KCCSNUnion_GetbyKCCSN1(T0002053_RightKccUp_SN).SN;

                if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002053_Right_SN, "T0002053", out message))
                {
                    if (ProConditionHelper.CheckSubSNsPrecondition(T0002053_Right_SN, "T0002053", out message))
                    {
                        this.TextBox_T0002053_RightKccUp.Enabled = false;
                        this.TextBox_T0002053_RightKccDown.Enabled = true;
                        this.TextBox_T0002053_RightKccDown.Focus();
                        return;
                        //this.ConfirmSubmit.Enabled = false;
                    }
                }

            }
            else
            {
                message = "该KCC未装配过，请重新扫描正确的KCC！";
            }              
        }
       else
        {
            message = "T0002053风扇（左有网）KCC号与T0002053风扇（右无网）KCC号不能一致，请重新扫描！";
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002053_RightKccUp.Text = "";
        this.TextBox_T0002053_RightKccUp.Focus();
    }

    protected void TextBox_T0002053_RightKccDown_TextChanged(object sender, EventArgs e)
    {
        T0002053_RightKccDown_SN = this.TextBox_T0002053_RightKccDown.Text.Trim();
        if (SNHelper.KccDownSNCheck(T0002053_RightKccDown_SN, out message))
        {
            if (SNHelper.CheckKccDownPec(T0002053_RightKccDown_SN, kccDownPEC_2053, out message))
            {
                if (SNHelper.SNCheckKccDownVersion(T0002053_RightKccDown_SN, "01", out message))
                {
                    this.TextBox_T0002053_RightKccDown.Enabled = false;
                    this.ConfirmSubmit.Enabled = true;
                    this.ConfirmSubmit.Focus();
                    return;
                }
            }

        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.TextBox_T0002053_RightKccDown.Text = "";
        this.TextBox_T0002053_RightKccDown.Focus();
    }
    protected void ConfirmSubmit_Click(object sender, EventArgs e)
    {
        if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002358_KccUp_SN, out message))
        {
              if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002368_SN, "T0002368", out message))
              {
                  if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002049_Down_SN, "T0002049", out message))
                  {
                       if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002367_SN, "T0002367", out message))
                       {
                           if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002053_Left_SN, "T0002053", out message))
                           {
                               if (ProConditionHelper.CheckLeafSubSNsPrecondition(T0002053_Right_SN, "T0002053", out message))
                               {
                                   Unit u = new Unit();
                                   u.Insert(new UnitInfo() { SN = T0002358_TAK_SN, Tcode = "T0002358", IsLeaf = true, IsRoot = true });
                                   //  u.Insert(new UnitInfo() { SN = T0002368_SN, Tcode = "T0002368", IsLeaf = true, IsRoot = true });
                                   u.Insert(new UnitInfo() { SN = T0002049_Down_SN, Tcode = "T0002049", IsLeaf = true, IsRoot = true });
                                   u.Insert(new UnitInfo() { SN = T0002367_SN, Tcode = "T0002367", IsLeaf = true, IsRoot = true });
                                   u.Insert(new UnitInfo() { SN = T0002053_Left_SN, Tcode = "T0002053", IsLeaf = true, IsRoot = true });
                                   //u.Insert(new UnitInfo() { SN = T0002053_LeftKccUp_SN, Tcode = "T0002053", IsLeaf = true, IsRoot = true });
                                   // u.Insert(new UnitInfo() { SN = T0002053_LeftKccDown_SN, Tcode = "T0002053", IsLeaf = true, IsRoot = true });
                                   u.Insert(new UnitInfo() { SN = T0002053_Right_SN, Tcode = "T0002053", IsLeaf = true, IsRoot = true });
                                   // u.Insert(new UnitInfo() { SN = T0002053_RightKccUp_SN, Tcode = "T0002053", IsLeaf = true, IsRoot = true });
                                   //u.Insert(new UnitInfo() { SN = T0002053_RightKccDown_SN, Tcode = "T0002053", IsLeaf = true, IsRoot = true });
                                   KCCSNUnion ku = new KCCSNUnion();
                                   KCCSNUnionInfo kui_2036 = new KCCSNUnionInfo() { KCCSN1 = T0002358_KccUp_SN, KCCSN2 = T0002358_KccDown_SN, SN = T0002358_TAK_SN, UserID = "111113" };
                                   ku.Insert(kui_2036);
                                   // KCCSNUnionInfo kui = new KCCSNUnionInfo() { KCCSN1 = T0002053_LeftKccUp_SN, KCCSN2 = T0002053_LeftKccDown_SN, SN = T0002053_Left_SN, UserID = "111113" };
                                   // ku.Insert(kui);
                                   //  KCCSNUnionInfo kuiOther = new KCCSNUnionInfo() { KCCSN1 = T0002053_RightKccUp_SN, KCCSN2 = T0002053_RightKccDown_SN, SN = T0002053_Right_SN, UserID = "111113" };
                                   //  ku.Insert(kuiOther);

                                   AssembleInfo ainfo = new AssembleInfo()
                                   {
                                       ID = 1,
                                       SN = T0002358_TAK_SN,
                                       IsRoot = true,
                                       RecordTime = DateTime.Now,
                                       Tcode = "T0002358",
                                       Userid = "111113"
                                   };
                                   dt.Rows.Clear();
                                   dr = dt.NewRow();
                                   dr["SubSN"] = T0002368_SN;
                                   dr["Remark"] = "DM_T0002368";
                                   dt.Rows.Add(dr);

                                   dr = dt.NewRow();
                                   dr["SubSN"] = T0002049_Down_SN;
                                   dr["Remark"] = "DM_T0002049_Down";
                                   dt.Rows.Add(dr);

                                   dr = dt.NewRow();
                                   dr["SubSN"] = T0002367_SN;
                                   dr["Remark"] = "DM_T0002367";
                                   dt.Rows.Add(dr);

                                   dr = dt.NewRow();
                                   dr["SubSN"] = T0002053_Left_SN;
                                   dr["Remark"] = "DM_T0002053_Left";
                                   dt.Rows.Add(dr);

                                   /* dt.Rows.Clear();
                                    dr = dt.NewRow();
                                    dr["SubSN"] = T0002053_LeftKccUp_SN;
                                    dr["Remark"] = "DM_T0002053_LeftKccUp";
                                    dt.Rows.Add(dr);

                                    dr = dt.NewRow();
                                    dr["SubSN"] = T0002053_LeftKccDown_SN;
                                    dr["Remark"] = "DM_T0002053_LeftKccDown";
                                    dt.Rows.Add(dr);*/

                                   dr = dt.NewRow();
                                   dr["SubSN"] = T0002053_Right_SN;
                                   dr["Remark"] = "DM_T0002053_Right";
                                   dt.Rows.Add(dr);

                                   /*  dr = dt.NewRow();
                                     dr["SubSN"] = T0002053_RightKccUp_SN;
                                     dr["Remark"] = "DM_T0002053_RightKccUp";
                                     dt.Rows.Add(dr);

                                     dr = dt.NewRow();
                                     dr["SubSN"] = T0002053_RightKccDown_SN;
                                     dr["Remark"] = "DM_T0002053_RightKccDown";
                                     dt.Rows.Add(dr);*/

                                   if (a.Assemble_Insert(ainfo, dt))
                                   {
                                       message = "录入成功";

                                       this.TextBox_T0002053_RightKccDown.Text = "";
                                       this.TextBox_T0002053_RightKccUp.Text = "";
                                       this.TextBox_T0002053_LeftKccDown.Text = "";
                                       this.TextBox_T0002053_LeftKccUp.Text = "";
                                       this.TextBox_T0002367_KccDown.Text = "";
                                       this.TextBox_T0002367_KccUp.Text = "";
                                       this.TextBox_T0002049_DownKccDown.Text = "";
                                       this.TextBox_T0002049_Up.Text = "";
                                       this.TextBox_T0002368_KccDown.Text = "";
                                       this.TextBox_T0002368_KccUp.Text = "";
                                       this.TextBox_T0002368_KccUp.Enabled = true;
                                       this.TextBox_T0002368_KccUp.Focus();
                                       this.ConfirmSubmit.Enabled = false;

                                   }
                                   else
                                   {
                                       message = "录入失败，请联系相关人员";
                                   }
                               }
                           }        
                       }       
                  }       
              }       
        }      
       
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
    }
    protected void Return_Click(object sender, EventArgs e)
    {
        Response.Redirect("DM.aspx");
    }





  
}